// 数据类型
const GRID_TYPE = {
  DISABLED: "disabled",
  INPUT: "text",
  INT: "int",
  FLOAT: "float",
  SELECT: "select",
  CHECKBOX: "checkbox",
  COLOR: "color",
  BUTTON: "button",
};
type GridType = (typeof GRID_TYPE)[keyof typeof GRID_TYPE];

// 材料类型
const MATERIAL_TYPE = {
  MAT1: "MAT1",
  MAT8: "MAT8",
  MAT9: "MAT9",
};
// 1️⃣ 材料卡片props
interface BaseProp {
  type: GridType;
  title: string;
}
interface SelectProp extends BaseProp {
  type: typeof GRID_TYPE.SELECT;
  options: { label: string; value: string | number }[];
}

interface InputProp extends BaseProp {
  type:
    | typeof GRID_TYPE.INPUT
    | typeof GRID_TYPE.DISABLED
    | typeof GRID_TYPE.COLOR
    | typeof GRID_TYPE.FLOAT
    | typeof GRID_TYPE.INT
    | typeof GRID_TYPE.CHECKBOX
    | typeof GRID_TYPE.BUTTON;
}

interface MaterialEditorProps {
  name: InputProp;
  id: InputProp;
  color: InputProp;
  include: InputProp;
  type: SelectProp;
  base_material: InputProp;
  elasticModulus?: InputProp;
  shearModulus?: InputProp;
  poissonsRatio?: InputProp;
  density: InputProp;
  thermExpanCoeff?: InputProp;
  tensionStressLimit?: InputProp;
  compressStressLimit?: InputProp;
  shearStressLimit?: InputProp;
  refTemperature?: InputProp;
  dampingCoeff?: InputProp;
  stiffness?: InputProp;
  elasticModulus11: InputProp;
  elasticModulus22: InputProp;
  shearModulus12: InputProp;
  shearModulus13: InputProp;
  thermExpanCoeff11: InputProp;
  thermExpanCoeff22: InputProp;
  tensionStressLimit11: InputProp;
  tensionStressLimit22: InputProp;
  compressStressLimit11: InputProp;
  compressStressLimit22: InputProp;
  stiffness11: InputProp;
  stiffness12: InputProp;
  stiffness13: InputProp;
  stiffness14: InputProp;
  stiffness15: InputProp;
  stiffness16: InputProp;
  stiffness22: InputProp;
  stiffness23: InputProp;
  stiffness24: InputProp;
  stiffness25: InputProp;
  stiffness26: InputProp;
  stiffness33: InputProp;
  stiffness34: InputProp;
  stiffness35: InputProp;
  stiffness36: InputProp;
  stiffness44: InputProp;
  stiffness45: InputProp;
  stiffness46: InputProp;
  stiffness55: InputProp;
  stiffness56: InputProp;
  stiffness66: InputProp;
  thermExpanCoeff33: InputProp;
  thermExpanCoeff12: InputProp;
  thermExpanCoeff31: InputProp;
  thermExpanCoeff23: InputProp;
  poissonsRatio12: InputProp;
  todo?: InputProp;
}

const materialEditorProps: MaterialEditorProps = {
  poissonsRatio12: {
    type: GRID_TYPE.FLOAT,
    title: "泊松比12",
  },
  shearModulus12: {
    type: GRID_TYPE.FLOAT,
    title: "剪切模量12",
  },
  shearModulus13: {
    type: GRID_TYPE.FLOAT,
    title: "剪切模量13",
  },
  elasticModulus11: {
    type: GRID_TYPE.FLOAT,
    title: "弹性模量11",
  },
  elasticModulus22: {
    type: GRID_TYPE.FLOAT,
    title: "弹性模量22",
  },
  name: {
    type: GRID_TYPE.INPUT,
    title: "名字",
  },
  id: {
    type: GRID_TYPE.DISABLED,
    title: "标识",
  },
  color: {
    type: GRID_TYPE.COLOR,
    title: "颜色",
  },
  include: {
    type: GRID_TYPE.INPUT,
    title: "包含文件",
  },
  type: {
    type: GRID_TYPE.SELECT,
    title: "类型",
    options: [
      {
        label: "MAT1",
        value: "MAT1",
      },
      {
        label: "MAT8",
        value: "MAT8",
      },
      {
        label: "MAT9",
        value: "MAT9",
      },
    ],
  },
  base_material: {
    title: "基础材料",
    type: GRID_TYPE.BUTTON,
  },
  elasticModulus: {
    type: GRID_TYPE.FLOAT,
    title: "弹性模量",
  },
  shearModulus: {
    type: GRID_TYPE.FLOAT,
    title: "剪切模量",
  },
  poissonsRatio: {
    type: GRID_TYPE.FLOAT,
    title: "泊松比",
  },
  density: {
    type: GRID_TYPE.FLOAT,
    title: "密度",
  },
  thermExpanCoeff: {
    type: GRID_TYPE.FLOAT,
    title: "热膨胀系数",
  },
  tensionStressLimit: {
    type: GRID_TYPE.FLOAT,
    title: "拉伸应力极限",
  },
  compressStressLimit: {
    type: GRID_TYPE.FLOAT,
    title: "压缩应力极限",
  },
  shearStressLimit: {
    type: GRID_TYPE.FLOAT,
    title: "剪切应力极限",
  },
  refTemperature: {
    type: GRID_TYPE.FLOAT,
    title: "参考温度",
  },
  dampingCoeff: {
    type: GRID_TYPE.FLOAT,
    title: "阻尼系数",
  },
  stiffness: {
    type: GRID_TYPE.FLOAT,
    title: "刚度",
  },
  thermExpanCoeff11: {
    type: GRID_TYPE.FLOAT,
    title: "热膨胀系数11",
  },
  thermExpanCoeff22: {
    type: GRID_TYPE.FLOAT,
    title: "热膨胀系数22",
  },
  tensionStressLimit11: {
    type: GRID_TYPE.FLOAT,
    title: "拉伸应力极限11",
  },
  tensionStressLimit22: {
    type: GRID_TYPE.FLOAT,
    title: "拉伸应力极限22",
  },
  compressStressLimit11: {
    type: GRID_TYPE.FLOAT,
    title: "压缩应力极限11",
  },
  compressStressLimit22: {
    type: GRID_TYPE.FLOAT,
    title: "压缩应力极限22",
  },
  stiffness11: {
    type: GRID_TYPE.FLOAT,
    title: "刚度11",
  },
  stiffness12: {
    type: GRID_TYPE.FLOAT,
    title: "刚度12",
  },
  stiffness13: {
    type: GRID_TYPE.FLOAT,
    title: "刚度13",
  },
  stiffness14: {
    type: GRID_TYPE.FLOAT,
    title: "刚度14",
  },
  stiffness15: {
    type: GRID_TYPE.FLOAT,
    title: "刚度15",
  },
  stiffness16: {
    type: GRID_TYPE.FLOAT,
    title: "刚度16",
  },
  stiffness22: {
    type: GRID_TYPE.FLOAT,
    title: "刚度22",
  },
  stiffness23: {
    type: GRID_TYPE.FLOAT,
    title: "刚度23",
  },
  stiffness24: {
    type: GRID_TYPE.FLOAT,
    title: "刚度24",
  },
  stiffness25: {
    type: GRID_TYPE.FLOAT,
    title: "刚度25",
  },
  stiffness26: {
    type: GRID_TYPE.FLOAT,
    title: "刚度26",
  },
  stiffness33: {
    type: GRID_TYPE.FLOAT,
    title: "刚度33",
  },
  stiffness34: {
    type: GRID_TYPE.FLOAT,
    title: "刚度34",
  },
  stiffness35: {
    type: GRID_TYPE.FLOAT,
    title: "刚度35",
  },
  stiffness36: {
    type: GRID_TYPE.FLOAT,
    title: "刚度36",
  },
  stiffness44: {
    type: GRID_TYPE.FLOAT,
    title: "刚度44",
  },
  stiffness45: {
    type: GRID_TYPE.FLOAT,
    title: "刚度45",
  },
  stiffness46: {
    type: GRID_TYPE.FLOAT,
    title: "刚度46",
  },
  stiffness55: {
    type: GRID_TYPE.FLOAT,
    title: "刚度55",
  },
  stiffness56: {
    type: GRID_TYPE.FLOAT,
    title: "刚度56",
  },
  stiffness66: {
    type: GRID_TYPE.FLOAT,
    title: "刚度66",
  },
  thermExpanCoeff33: {
    type: GRID_TYPE.FLOAT,
    title: "热膨胀系数33",
  },
  thermExpanCoeff12: {
    type: GRID_TYPE.FLOAT,
    title: "热膨胀系数12",
  },
  thermExpanCoeff31: {
    type: GRID_TYPE.FLOAT,
    title: "热膨胀系数31",
  },
  thermExpanCoeff23: {
    type: GRID_TYPE.FLOAT,
    title: "热膨胀系数23",
  },
};

// type: MAT1
interface MAT1 {
  name: string;
  id: string;
  color: string;
  include: string;
  type: "MAT1";
  base_material: string;
  elasticModulus: string;
  shearModulus: string;
  poissonsRatio: string;
  density: string;
  thermExpanCoeff: string;
  tensionStressLimit: string;
  compressStressLimit: string;
  shearStressLimit: string;
}
interface LoadConstraint {
  name: string;
  id: string;
  // color: string;
  include: string;
  loadConstraintType: string;
}
// 坐标系管理
interface LoadCoordinates {
  name: string;
  id: string;
  // color: string;
  include: string;
  description: string;
  definitionMode: string;
  originalNode: string;
  zNode: string;
  xzPlanePoint: string;
  coordinateType: string;
  size: string;
}
interface LoadCoordinatesEditorProps {
  name: InputProp;
  id: InputProp;
  include: InputProp;
  description: InputProp;
  definitionMode: CheckboxProp;
  originalNode: InputProp;
  zNode: InputProp;
  xzPlanePoint: InputProp;
  coordinateType: SelectProp;
  size: InputProp;
}
interface LoadConstraintEditorProps {
  name: InputProp;
  id: InputProp;
  // color: InputProp;
  include: InputProp;
  loadConstraintType: InputProp;
}
const loadCoordinatesEditorProps: LoadCoordinatesEditorProps = {
  name: {
    type: GRID_TYPE.INPUT,
    title: "名字",
  },
  id: {
    type: GRID_TYPE.DISABLED,
    title: "标识",
  },
  include: {
    type: GRID_TYPE.INPUT,
    title: "包含文件",
  },
  description: {
    type: GRID_TYPE.INPUT,
    title: "描述",
  },
  definitionMode: {
    type: GRID_TYPE.CHECKBOX,
    title: "定义方式",
  },
  originalNode: {
    type: GRID_TYPE.BUTTON,
    title: "原始节点",
  },
  zNode: {
    type: GRID_TYPE.BUTTON,
    title: "z轴节点",
  },
  xzPlanePoint: {
    type: GRID_TYPE.BUTTON,
    title: "xz轴平面点",
  },
  coordinateType: {
    type: GRID_TYPE.SELECT,
    title: "坐标类型",
    options: [
      {
        label: "Rectangular",
        value: "0",
      },
      {
        label: "Cylindrical",
        value: "1",
      },
      {
        label: "Spherical",
        value: "2",
      },
    ],
  },
  size: {
    type: GRID_TYPE.INPUT,
    title: "相对大小",
  },
};
const initialCoordinates: LoadCoordinates = {
  name: "coordinates_1",
  id: "1",
  include: "Main Model",
  description: "",
  definitionMode: "",
  originalNode: "",
  zNode: "",
  xzPlanePoint: "",
  coordinateType: "0",
  size: "10",
};
export function parseLoadCoordinates(m: { [x: string]: any }) {
  const loadCoordinates: LoadCoordinates = {
    name: m["name"],
    id: m["id"],
    include: "Main Model",
    description: "",
    definitionMode: "",
    originalNode: "",
    zNode: "",
    xzPlanePoint: "",
    coordinateType: "0",
    size: "10",
  };
  return loadCoordinates;
}
const loadConstraintEditorProps: LoadConstraintEditorProps = {
  name: {
    type: GRID_TYPE.INPUT,
    title: "名字",
  },
  id: {
    type: GRID_TYPE.DISABLED,
    title: "标识",
  },
  // color: {
  //   type: GRID_TYPE.COLOR,
  //   title: "颜色",
  // },
  loadConstraintType: {
    type: GRID_TYPE.DISABLED,
    title: "卡片类型",
  },
  include: {
    type: GRID_TYPE.INPUT,
    title: "包含文件",
  },
};

const initialLoadConstraint: LoadConstraint = {
  name: "ForceSet_1",
  id: "1",
  // color: "#000000",
  loadConstraintType: "loadConstraint",
  include: "Main Model",
};
interface Displacement {
  id: string;
  name: string;
  displacemnetType: "SPC";
  applyTo: number;
  curveNames: string;
  DisplacementChooseSubject: string;
  dof1: boolean;
  dof1Value: string;
  dof2: boolean;
  dof2Value: string;
  dof3: boolean;
  dof3Value: string;
  dof4: boolean;
  dof4Value: string;
  dof5: boolean;
  dof5Value: string;
  dof6: boolean;
  dof6Value: string;
}
interface DisplacementEditorProps {
  id: InputProp;
  name: InputProp;
  displacemnetType: InputProp;
  applyTo: SelectProp;
  curveNames: SelectProp;
  DisplacementChooseSubject: InputProp;
  dof1: CheckboxProp;
  dof1Value: InputProp;
  dof2: CheckboxProp;
  dof2Value: InputProp;
  dof3: CheckboxProp;
  dof3Value: InputProp;
  dof4: CheckboxProp;
  dof4Value: InputProp;
  dof5: CheckboxProp;
  dof5Value: InputProp;
  dof6: CheckboxProp;
  dof6Value: InputProp;
}
const displacementEditorProps: DisplacementEditorProps = {
  id: {
    type: GRID_TYPE.DISABLED,
    title: "标识",
  },
  name: {
    type: GRID_TYPE.INPUT,
    title: "名字",
  },
  displacemnetType: {
    type: GRID_TYPE.DISABLED,
    title: "displacemnetType",
  },
  applyTo: {
    type: GRID_TYPE.SELECT,
    title: "应用到",
    options: [
      {
        label: "node",
        value: 0,
      },
      {
        label: "vertex",
        value: 1,
      },
      {
        label: "edge",
        value: 2,
      },
      {
        label: "face",
        value: 3,
      },
      {
        label: "nodeSet",
        value: 4,
      },
    ],
  },
  curveNames: {
    type: GRID_TYPE.SELECT,
    title: "幅值曲线",
    options: [
      {
        label: "Ramp",
        value: "Ramp",
      },
    ],
  },
  DisplacementChooseSubject: {
    type: GRID_TYPE.BUTTON,
    title: "选择对象",
  },
  dof1: {
    type: GRID_TYPE.CHECKBOX,
    title: "自由度1",
  },
  dof1Value: {
    type: GRID_TYPE.INPUT,
    title: "自由度1值",
  },
  dof2: {
    type: GRID_TYPE.CHECKBOX,
    title: "自由度2",
  },
  dof2Value: {
    type: GRID_TYPE.INPUT,
    title: "自由度2值",
  },
  dof3: {
    type: GRID_TYPE.CHECKBOX,
    title: "自由度3",
  },
  dof3Value: {
    type: GRID_TYPE.INPUT,
    title: "自由度3值",
  },
  dof4: {
    type: GRID_TYPE.CHECKBOX,
    title: "自由度4",
  },
  dof4Value: {
    type: GRID_TYPE.INPUT,
    title: "自由度4值",
  },
  dof5: {
    type: GRID_TYPE.CHECKBOX,
    title: "自由度5",
  },
  dof5Value: {
    type: GRID_TYPE.INPUT,
    title: "自由度5值",
  },
  dof6: {
    type: GRID_TYPE.CHECKBOX,
    title: "自由度6",
  },
  dof6Value: {
    type: GRID_TYPE.INPUT,
    title: "自由度6值",
  },
};
const initialDisplacement: Displacement = {
  id: "1",
  name: "Displacemnet_1",
  displacemnetType: "SPC",
  applyTo: 0,
  curveNames: "Ramp",
  DisplacementChooseSubject: "choose",
  dof1: true,
  dof1Value: "0.0",
  dof2: true,
  dof2Value: "0.0",
  dof3: true,
  dof3Value: "0.0",
  dof4: true,
  dof4Value: "0.0",
  dof5: true,
  dof5Value: "0.0",
  dof6: true,
  dof6Value: "0.0",
};
interface NodesSet {
  id: string;
  name: string;
  includeFile: string;
  setType: string;
  nodeSet: string;
}
const initialNodesSet: NodesSet = {
  id: "1",
  name: "Set_1",
  includeFile: "Main Model",
  setType: "node",
  nodeSet: "0 node(s)",
};
interface ElementsSet {
  id: string;
  name: string;
  includeFile: string;
  setType: string;
  elementSet: string;
}
const initialElementsSet: ElementsSet = {
  id: "1",
  name: "Set_1",
  includeFile: "Main Model",
  setType: "element",
  elementSet: "0 element(s)",
};
interface ComponentsSet {
  id: string;
  name: string;
  includeFile: string;
  setType: string;
  componentSet: string;
  componentsType: string;
}
const initialComponentsSet: ComponentsSet = {
  id: "1",
  name: "Set_1",
  includeFile: "Main Model",
  setType: "component",
  componentSet: "0 component(s)",
  componentsType: "0",
};
interface SetsSet {
  id: string;
  name: string;
  includeFile: string;
  setType: string;
  setSet: string;
  setsType: string;
}
const initialSetsSet: SetsSet = {
  id: "1",
  name: "Set_1",
  includeFile: "Main Model",
  setType: "set",
  setSet: "0 set(s)",
  setsType: "0",
};
interface SetEditorProps {
  id: InputProp;
  name: InputProp;
  includeFile: InputProp;
  setType: SelectProp;
  nodeSet?: InputProp;
  elementSet?: InputProp;
  componentSet?: InputProp;
  componentsType?: SelectProp;
  setSet?: InputProp;
  setsType?: SelectProp;
}
const setEditorProps: SetEditorProps = {
  name: {
    type: GRID_TYPE.INPUT,
    title: "名字",
  },
  id: {
    type: GRID_TYPE.DISABLED,
    title: "标识",
  },
  includeFile: {
    type: GRID_TYPE.DISABLED,
    title: "包含文件",
  },
  setType: {
    type: GRID_TYPE.SELECT,
    title: "类型",
    options: [
      {
        label: "Nodes",
        value: "node",
      },
      {
        label: "Elements",
        value: "element",
      },
      {
        label: "Components",
        value: "component",
      },
      {
        label: "Sets",
        value: "set",
      },
    ],
  },
  nodeSet: {
    type: GRID_TYPE.BUTTON,
    title: "节点",
  },
  elementSet: {
    type: GRID_TYPE.BUTTON,
    title: "单元",
  },
  componentSet: {
    type: GRID_TYPE.BUTTON,
    title: "组件",
  },
  componentsType: {
    type: GRID_TYPE.SELECT,
    title: "组件集类型",
    options: [
      {
        label: "Elset",
        value: 0,
      },
      {
        label: "Nset",
        value: 1,
      },
    ],
  },
  setSet: {
    type: GRID_TYPE.BUTTON,
    title: "集合",
  },
  setsType: {
    type: GRID_TYPE.SELECT,
    title: "集合的集合类型",
    options: [
      {
        label: "Elset",
        value: 0,
      },
      {
        label: "Nset by Elset",
        value: 1,
      },
      {
        label: "Nset",
        value: 2,
      },
    ],
  },
};
const SETS_TYPE_initial = {
  NodesSet: initialNodesSet,
  ElementsSet: initialElementsSet,
  ComponentsSet: initialComponentsSet,
  SetsSet: initialSetsSet,
};
type SetsTypeInitial = typeof SETS_TYPE_initial;
interface Force {
  id: string;
  name: string;
  forceType: "FORCE";
  applyTo: number;
  curveNames: string;
  coordinateSystemType: string;
  ForceChooseSubject: string;
  magnitude: string;
  directionX: string;
  directionY: string;
  directionZ: string;
}
interface ForceEditorProps {
  id: InputProp;
  name: InputProp;
  forceType: InputProp;
  applyTo: SelectProp;
  curveNames: SelectProp;
  coordinateSystemType: InputProp;
  ForceChooseSubject: InputProp;
  magnitude: InputProp;
  directionX: InputProp;
  directionY: InputProp;
  directionZ: InputProp;
}
const forceEditorProps: ForceEditorProps = {
  id: {
    type: GRID_TYPE.DISABLED,
    title: "标识",
  },
  name: {
    type: GRID_TYPE.INPUT,
    title: "名字",
  },
  forceType: {
    type: GRID_TYPE.DISABLED,
    title: "forceType",
  },
  applyTo: {
    type: GRID_TYPE.SELECT,
    title: "应用到",
    options: [
      {
        label: "node",
        value: 0,
      },
      {
        label: "vertex",
        value: 1,
      },
      {
        label: "edge",
        value: 2,
      },
      {
        label: "face",
        value: 3,
      },
      {
        label: "nodeSet",
        value: 4,
      },
    ],
  },
  curveNames: {
    type: GRID_TYPE.SELECT,
    title: "幅值曲线",
    options: [
      {
        label: "Ramp",
        value: "Ramp",
      },
    ],
  },
  coordinateSystemType: {
    type: GRID_TYPE.INPUT,
    title: "坐标系类型",
  },
  ForceChooseSubject: {
    type: GRID_TYPE.BUTTON,
    title: "选择对象",
  },
  magnitude: {
    type: GRID_TYPE.INPUT,
    title: "大小",
  },
  directionX: {
    type: GRID_TYPE.INPUT,
    title: "方向x",
  },
  directionY: {
    type: GRID_TYPE.INPUT,
    title: "方向y",
  },
  directionZ: {
    type: GRID_TYPE.INPUT,
    title: "方向z",
  },
};
const initialForce: Force = {
  id: "1",
  name: "Force_1",
  forceType: "FORCE",
  applyTo: 0,
  curveNames: "Ramp",
  coordinateSystemType: "Global System",
  ForceChooseSubject: "choose",
  magnitude: "0.0",
  directionX: "0.0",
  directionY: "0.0",
  directionZ: "0.0",
};
function parseMaterial(m: { [x: string]: any }) {
  console.log("material:", m);
  if (m["type"] == "MAT1") {
    const material: MAT1 = {
      name: m["name"],
      id: m["id"],
      color: m["color"],
      density: m["density"],
      include: m["includeFile"],
      type: "MAT1",
      base_material: "请选择基础材料",
      elasticModulus: m["elasticModulus"],
      shearModulus: m["shearModulus"],
      poissonsRatio: m["poissonsRatio"],
      thermExpanCoeff: m["thermExpanCoeff"],
      tensionStressLimit: m["tensionStressLimit"],
      compressStressLimit: m["compressStressLimit"],
      shearStressLimit: m["shearStressLimit"],
    };
    return material;
  } else if (m["type"] == "MAT8") {
    const material: MAT8 = {
      name: m["name"],
      id: m["id"],
      color: m["color"],
      density: m["density"],
      include: m["includeFile"],
      type: "MAT8",
      base_material: "请选择基础材料",
      shearStressLimit: m["shearStressLimit"],
      elasticModulus11: m["elasticModulus11"],
      elasticModulus22: m["elasticModulus22"],
      shearModulus12: m["shearModulus12"],
      shearModulus13: m["shearModulus13"],
      poissonsRatio12: m["poissonsRatio12"],
      thermExpanCoeff11: m["thermExpanCoeff11"],
      thermExpanCoeff22: m["thermExpanCoeff22"],
      dampingCoeff: m["dampingCoeff"],
      refTemperature: m["refTemperature"],
      tensionStressLimit11: m["tensionStressLimit11"],
      tensionStressLimit22: m["tensionStressLimit22"],
      compressStressLimit11: m["compressStressLimit11"],
      compressStressLimit22: m["compressStressLimit22"],
    };
    return material;
  } else if (m["type"] == "MAT9") {
    const material: MAT9 = {
      name: m["name"],
      id: m["id"],
      color: m["color"],
      density: m["density"],
      include: m["includeFile"],
      type: "MAT9",
      base_material: "请选择基础材料",
      stiffness11: m["stiffness11"],
      stiffness12: m["stiffness12"],
      stiffness13: m["stiffness13"],
      stiffness14: m["stiffness14"],
      stiffness15: m["stiffness15"],
      stiffness16: m["stiffness16"],
      stiffness22: m["stiffness22"],
      stiffness23: m["stiffness23"],
      stiffness24: m["stiffness24"],
      stiffness25: m["stiffness25"],
      stiffness26: m["stiffness26"],
      stiffness33: m["stiffness33"],
      stiffness34: m["stiffness34"],
      stiffness35: m["stiffness35"],
      stiffness36: m["stiffness36"],
      stiffness44: m["stiffness44"],
      stiffness45: m["stiffness45"],
      stiffness46: m["stiffness46"],
      stiffness55: m["stiffness55"],
      stiffness56: m["stiffness56"],
      stiffness66: m["stiffness66"],
      thermExpanCoeff11: m["thermExpanCoeff11"],
      thermExpanCoeff22: m["thermExpanCoeff22"],
      thermExpanCoeff33: m["thermExpanCoeff33"],
      thermExpanCoeff12: m["thermExpanCoeff12"],
      thermExpanCoeff31: m["thermExpanCoeff31"],
      thermExpanCoeff23: m["thermExpanCoeff23"],
      dampingCoeff: m["dampingCoeff"],
      refTemperature: m["refTemperature"],
    };
    return material;
  } else if (m["type"] == undefined) {
    const material: MAT1 = {
      name: m["name"],
      id: m["id"],
      color: m["color"],
      density: m["density"],
      include: m["includeFile"],
      type: "MAT1",
      base_material: "请选择基础材料",
      elasticModulus: m["elasticModulus"],
      shearModulus: m["shearModulus"],
      poissonsRatio: m["poissonsRatio"],
      thermExpanCoeff: m["thermExpanCoeff"],
      tensionStressLimit: m["tensionStressLimit"],
      compressStressLimit: m["compressStressLimit"],
      shearStressLimit: m["shearStressLimit"],
    };
    return material;
  }
  alert("can not handle material type:" + m["type"]);
  return initialMaterialMAT1;
}
export function parseLoadConstraints(m: { [x: string]: any }) {
  const loadConstraints: LoadConstraint = {
    name: m["name"],
    id: m["id"],
    // color: initialLoadConstraint.color,
    include: initialLoadConstraint.include,
    loadConstraintType: initialLoadConstraint.loadConstraintType,
  };
  return loadConstraints;
}
export function parseForce(m: { [x: string]: any }) {
  const force: Force = {
    name: m["name"],
    id: m["id"],
    forceType: initialForce.forceType,
    applyTo: m["applyTo"],
    curveNames: initialForce.curveNames,
    coordinateSystemType: initialForce.coordinateSystemType,
    ForceChooseSubject: initialForce.ForceChooseSubject,
    magnitude: m["magnitude"],
    directionX: m["directionX"],
    directionY: m["directionY"],
    directionZ: m["directionZ"],
  };
  return force;
}
export function parseDisplacement(m: { [x: string]: any }) {
  const displacement: Displacement = {
    name: m["name"],
    id: m["id"],
    displacemnetType: "SPC",
    applyTo: m["applyTo"],
    curveNames: m["curveNames"],
    DisplacementChooseSubject: "choose",
    dof1: m["dof1"],
    dof1Value: m["dof1Value"],
    dof2: m["dof2"],
    dof2Value: m["dof2Value"],
    dof3: m["dof3"],
    dof3Value: m["dof3Value"],
    dof4: m["dof4"],
    dof4Value: m["dof4Value"],
    dof5: m["dof5"],
    dof5Value: m["dof5Value"],
    dof6: m["dof6"],
    dof6Value: m["dof6Value"],
  };
  return displacement;
}

function parseSet(m: { [x: string]: any }) {
  if (m["setType"] == "node") {
    // TODO: 待完善
    const nodesSet: NodesSet = {
      id: m["id"],
      name: m["name"],
      includeFile: m["includeFile"],
      setType: m["setType"],
      nodeSet: "",
    };
    return nodesSet;
  } else if (m["setType"] == "element") {
    // TODO: 待完善
    const elementsSet: ElementsSet = {
      id: m["id"],
      name: m["name"],
      includeFile: m["includeFile"],
      setType: m["setType"],
      elementSet: "",
    };
    return elementsSet;
  } else if (m["setType"] == "component") {
    // TODO: 待完善
    const componentsSet: ComponentsSet = {
      id: m["id"],
      name: m["name"],
      includeFile: m["includeFile"],
      setType: m["setType"],
      componentSet: "",
      componentsType: m["componentsType"],
    };
    return componentsSet;
  } else if (m["setType"] == "set") {
    // TODO: 待完善
    const setsSet: SetsSet = {
      id: m["id"],
      name: m["name"],
      includeFile: m["includeFile"],
      setType: m["setType"],
      setSet: "",
      setsType: m["setType"],
    };
    return setsSet;
  } else {
    alert("未知集合类型");
    return initialElementsSet;
  }
}

function parseProperty(p: { [x: string]: any }) {
  if (p["type"] == "PBUSH") {
    const property: PBUSH = {
      name: p["name"],
      id: p["id"],
      color: p.color,
      include: p["includeFile"],
      type: "PBUSH",
      stiffness: {
        value: p["K-Line"],
        k1: p["k1"],
        k2: p["k2"],
        k3: p["k3"],
        k4: p["k4"],
        k5: p["k5"],
        k6: p["k6"],
      },
    };
    return property;
  }
  if (p["type"] == "PCOMP") {
    const property: PCOMP = {
      name: p["name"],
      id: p["id"],
      color: p.color,
      include: p["includeFile"],
      type: "PCOMP",
      Z0: p["Z0"],
      nonstructuralMass: p["nonstructuralMass"],
      bendingShear: p["bendingShear"],
      failureTheory: p["failureTheory"],
      refTemperature: p["refTemperature"],
      dampingCoeff: p["dampingCoeff"],
      laminateOptions: p["laminateOptions"],
      numOfPlies: {
        value: p["numOfPlies"],
        material: p["materialIndex"],
        thickness: p["thickness"],
        theta: p["theta"],
        sout: p["sout"],
        editor: p["numOfPlies"] + " row(s)",
      },
    };
    if (p["numOfPlies"] >= 1) {
      // TODO:
    }
    console.log("property:", property);
    return property;
  }
  if (p["type"] == "PSHELL") {
    const property: PSHELL = {
      name: p["name"],
      id: p["id"],
      color: p.color,
      include: p["includeFile"],
      type: "PSHELL",
      material: p["materialIndex"],
      thickness: p["thickness"],
    };
    return property;
  }
  return {
    name: p["name"],
    id: p["id"],
  };
}

const initialMaterialMAT1: MAT1 = {
  name: "MAT11",
  id: "123",
  color: "#000000",
  include: "main",
  type: "MAT1",
  base_material: "请选择基础材料",
  elasticModulus: "0.0",
  shearModulus: "0.0",
  poissonsRatio: "0.0",
  density: "0.0",
  thermExpanCoeff: "0.0",
  tensionStressLimit: "0.0",
  compressStressLimit: "0.0",
  shearStressLimit: "0.0",
};

// type: MAT8
interface MAT8 {
  name: string;
  id: string;
  color: string;
  include: string;
  type: "MAT8";
  base_material: "请选择基础材料";
  elasticModulus11: string;
  elasticModulus22: string;
  shearModulus12: string;
  shearModulus13: string;
  poissonsRatio12: string;
  density: string;
  thermExpanCoeff11: string;
  thermExpanCoeff22: string;
  dampingCoeff: string;
  refTemperature: string;
  tensionStressLimit11: string;
  tensionStressLimit22: string;
  compressStressLimit11: string;
  compressStressLimit22: string;
  shearStressLimit: string;
}

const initialMaterialMAT8: MAT8 = {
  name: "MAT888",
  id: "123",
  color: "#000000",
  include: "main",
  type: "MAT8",
  base_material: "请选择基础材料",
  elasticModulus11: "0.0",
  elasticModulus22: "0.0",
  shearModulus12: "0.0",
  shearModulus13: "0.0",
  poissonsRatio12: "0.0",
  density: "0.0",
  thermExpanCoeff11: "0.0",
  thermExpanCoeff22: "0.0",
  dampingCoeff: "0.0",
  refTemperature: "0.0",
  tensionStressLimit11: "0.0",
  tensionStressLimit22: "0.0",
  compressStressLimit11: "0.0",
  compressStressLimit22: "0.0",
  shearStressLimit: "0.0",
};

// type: MAT9
interface MAT9 {
  name: string;
  id: string;
  color: string;
  include: string;
  type: "MAT9";
  base_material: "请选择基础材料";
  stiffness11: string;
  stiffness12: string;
  stiffness13: string;
  stiffness14: string;
  stiffness15: string;
  stiffness16: string;
  stiffness22: string;
  stiffness23: string;
  stiffness24: string;
  stiffness25: string;
  stiffness26: string;
  stiffness33: string;
  stiffness34: string;
  stiffness35: string;
  stiffness36: string;
  stiffness44: string;
  stiffness45: string;
  stiffness46: string;
  stiffness55: string;
  stiffness56: string;
  stiffness66: string;
  density: string;
  thermExpanCoeff11: string;
  thermExpanCoeff22: string;
  thermExpanCoeff33: string;
  thermExpanCoeff12: string;
  thermExpanCoeff31: string;
  thermExpanCoeff23: string;
  dampingCoeff: string;
  refTemperature: string;
}

const initialMaterialMAT9: MAT9 = {
  name: "MAT9",
  id: "123",
  color: "#000000",
  include: "main",
  type: "MAT9",
  base_material: "请选择基础材料",
  stiffness11: "0.0",
  stiffness12: "0.0",
  stiffness13: "0.0",
  stiffness14: "0.0",
  stiffness15: "0.0",
  stiffness16: "0.0",
  stiffness22: "0.0",
  stiffness23: "0.0",
  stiffness24: "0.0",
  stiffness25: "0.0",
  stiffness26: "0.0",
  stiffness33: "0.0",
  stiffness34: "0.0",
  stiffness35: "0.0",
  stiffness36: "0.0",
  stiffness44: "0.0",
  stiffness45: "0.0",
  stiffness46: "0.0",
  stiffness55: "0.0",
  stiffness56: "0.0",
  stiffness66: "0.0",
  density: "0.0",
  thermExpanCoeff11: "0.0",
  thermExpanCoeff22: "0.0",
  thermExpanCoeff33: "0.0",
  thermExpanCoeff12: "0.0",
  thermExpanCoeff31: "0.0",
  thermExpanCoeff23: "0.0",
  dampingCoeff: "0.0",
  refTemperature: "0.0",
};

const MATERIAL_TYPE_initial = {
  MAT1: initialMaterialMAT1,
  MAT8: initialMaterialMAT8,
  MAT9: initialMaterialMAT9,
};
type MaterialTypeInitial = typeof MATERIAL_TYPE_initial;
const Load_Constraint_TYPE_initial = {
  LoadConstraint: initialLoadConstraint,
};
const Load_Coordinates_TYPE_initial = {
  LoadCoordinates: initialCoordinates,
};
const Force_TYPE_initial = {
  Force: initialForce,
};
const Displacement_TYPE_initial = {
  Displacement: initialDisplacement,
};
type LoadConstraintTYPEInitial = typeof Load_Constraint_TYPE_initial;
type ForceTYPEInitial = typeof Force_TYPE_initial;
type LoadCoordinateTYPEInitial = typeof Load_Coordinates_TYPE_initial;
type DisplacementTYPEInitial = typeof Displacement_TYPE_initial;

// 2️⃣ 属性卡片props
interface PropertyEditorProps {
  name: InputProp;
  id: InputProp;
  color: InputProp;
  include: InputProp;
  type: SelectProp;
  thickness?: InputProp;
  Z0?: InputProp;
  nonstructuralMass?: InputProp;
  bendingShear?: InputProp;
  failureTheory?: SelectProp;
  refTemperature?: InputProp;
  dampingCoeff?: InputProp;
  laminateOptions?: SelectProp;
  numOfPlies?: InputProp;
  material?: InputProp;
  theta?: InputProp;
  sout?: SelectProp;
  editor?: InputProp;
  stiffness?: InputProp;
  k1?: InputProp;
  k2?: InputProp;
  k3?: InputProp;
  k4?: InputProp;
  k5?: InputProp;
  k6?: InputProp;
}
const propertyEditorProps: PropertyEditorProps = {
  name: {
    type: GRID_TYPE.INPUT,
    title: "名字",
  },
  id: {
    type: GRID_TYPE.DISABLED,
    title: "标识",
  },
  color: {
    type: GRID_TYPE.COLOR,
    title: "颜色",
  },
  include: {
    type: GRID_TYPE.INPUT,
    title: "包含文件",
  },
  type: {
    type: GRID_TYPE.SELECT,
    title: "类型",
    options: [
      {
        label: "PSHELL",
        value: "PSHELL",
      },
      {
        label: "PCOMP",
        value: "PCOMP",
      },
      {
        label: "PBUSH",
        value: "PBUSH",
      },
    ],
  },
  thickness: {
    type: GRID_TYPE.FLOAT,
    title: "厚度",
  },
  Z0: {
    type: GRID_TYPE.FLOAT,
    title: "参考面至底面距离",
  },
  nonstructuralMass: {
    type: GRID_TYPE.FLOAT,
    title: "非结构质量",
  },
  bendingShear: {
    type: GRID_TYPE.FLOAT,
    title: "弯曲剪切",
  },
  failureTheory: {
    type: GRID_TYPE.SELECT,
    title: "失效理论",
    options: [
      {
        label: "OFF",
        value: "OFF",
      },
      {
        label: "HILL",
        value: "HILL",
      },
      {
        label: "HOFF",
        value: "HOFF",
      },
      {
        label: "TSAI",
        value: "TSAI",
      },
      {
        label: "STRN",
        value: "STRN",
      },
    ],
  },
  refTemperature: {
    type: GRID_TYPE.FLOAT,
    title: "参考温度",
  },
  dampingCoeff: {
    type: GRID_TYPE.FLOAT,
    title: "阻尼系数",
  },
  laminateOptions: {
    type: GRID_TYPE.SELECT,
    title: "层压板选项",
    options: [
      {
        label: "OFF",
        value: "OFF",
      },
      {
        label: "SYM",
        value: "SYM",
      },
      {
        label: "MEM",
        value: "MEM",
      },
      {
        label: "BENF",
        value: "BENF",
      },
      {
        label: "SMERA",
        value: "SMERA",
      },
      {
        label: "SMCORE",
        value: "SMCORE",
      },
    ],
  },
  numOfPlies: {
    type: GRID_TYPE.INT,
    title: "板层数量",
  },
  material: {
    type: GRID_TYPE.SELECT,
    title: "材料",
  },
  theta: {
    type: GRID_TYPE.FLOAT,
    title: "theta",
  },
  sout: {
    type: GRID_TYPE.SELECT,
    title: "应力/应变输出",
    options: [
      {
        label: "YES",
        value: "YES",
      },
      {
        label: "NO",
        value: "NO",
      },
    ],
  },
  editor: {
    type: GRID_TYPE.BUTTON,
    title: "编辑器",
  },
  stiffness: {
    type: GRID_TYPE.CHECKBOX,
    title: "刚度",
  },
  k1: {
    title: "k1",
    type: GRID_TYPE.FLOAT,
  },
  k2: {
    title: "k2",
    type: GRID_TYPE.FLOAT,
  },
  k3: {
    title: "k3",
    type: GRID_TYPE.FLOAT,
  },
  k4: {
    title: "k4",
    type: GRID_TYPE.FLOAT,
  },
  k5: {
    title: "k5",
    type: GRID_TYPE.FLOAT,
  },
  k6: {
    title: "k6",
    type: GRID_TYPE.FLOAT,
  },
};

// type: PSHELL
interface PSHELL {
  name: string;
  id: string;
  color: string;
  include: string;
  type: "PSHELL";
  material: string;
  thickness: number;
}

const initialPropertyPSHELL: PSHELL = {
  name: "property_1",
  id: "1",
  color: "#000000",
  include: "main model",
  type: "PSHELL",
  material: "Unspecified",
  thickness: 0.2,
};

// type: PCOMP
interface LayerPlateNumber {
  value: number;
  material: string;
  thickness: number;
  theta: number;
  sout: string;
  editor: string;
}

interface PCOMP {
  name: string;
  id: string;
  color: string;
  include: string;
  type: "PCOMP";
  Z0: number;
  nonstructuralMass: number;
  bendingShear: number;
  failureTheory: string;
  refTemperature: number;
  dampingCoeff: number;
  laminateOptions: string;
  numOfPlies: LayerPlateNumber;
}

const initialPropertyPCOMP: PCOMP = {
  name: "property_1",
  id: "1",
  color: "#000000",
  include: "main model",
  type: "PCOMP",
  Z0: 0.0,
  nonstructuralMass: 0.0,
  bendingShear: 0.0,
  failureTheory: "OFF",
  refTemperature: 0.0,
  dampingCoeff: 0.0,
  laminateOptions: "OFF",
  numOfPlies: {
    value: 1,
    material: "Unspecified",
    thickness: 0.0,
    theta: 0.0,
    sout: "YES",
    editor: "1 row(s)",
  },
};

// type: PBUSH
interface Stiffness {
  value: boolean;
  k1: number;
  k2: number;
  k3: number;
  k4: number;
  k5: number;
  k6: number;
}

interface PBUSH {
  name: string;
  id: string;
  color: string;
  include: string;
  type: "PBUSH";
  stiffness: Stiffness;
}

const initialPropertyPBUSH: PBUSH = {
  name: "property_1",
  id: "1",
  color: "#000000",
  include: "main model",
  type: "PBUSH",
  stiffness: {
    value: true,
    k1: 0.0,
    k2: 0.0,
    k3: 0.0,
    k4: 0.0,
    k5: 0.0,
    k6: 0.0,
  },
};

// 属性类型
const PROPERTY_TYPE = {
  PSHELL: "PSHELL",
  PCOMP: "PCOMP",
  PBUSH: "PBUSH",
};

// 属性卡片初始值
const PROPERTY_TYPE_initial = {
  PSHELL: initialPropertyPSHELL,
  PCOMP: initialPropertyPCOMP,
  PBUSH: initialPropertyPBUSH,
};
type PropertyTypeInitial = typeof PROPERTY_TYPE_initial;

interface CheckboxProp extends BaseProp {
  type: typeof GRID_TYPE.CHECKBOX;
}
// 3️⃣ 输出卡片props
interface OutputEditorProps {
  name: InputProp;
  id: InputProp;
  output: CheckboxProp;
  param: InputProp;
  output_name: CheckboxProp;
  variable: CheckboxProp;
  interval_num: CheckboxProp;
  time_interval: CheckboxProp;
  frequency: CheckboxProp;
  node_output: CheckboxProp;
  unit_output: CheckboxProp;
  contact_output: CheckboxProp;
  energy_output: CheckboxProp;
  Unsupported_Card: CheckboxProp;
  Row_input_Keywords: InputProp;
  Table_input_Keywords: InputProp;
}

const outputEditorProps: OutputEditorProps = {
  name: {
    type: GRID_TYPE.INPUT,
    title: "名字",
  },
  id: {
    type: GRID_TYPE.DISABLED,
    title: "标识",
  },
  output: {
    type: GRID_TYPE.CHECKBOX,
    title: "输出",
  },
  param: {
    type: GRID_TYPE.INPUT,
    title: "依赖参数",
  },
  output_name: {
    type: GRID_TYPE.CHECKBOX,
    title: "输出名称",
  },
  variable: {
    type: GRID_TYPE.CHECKBOX,
    title: "变量",
  },
  interval_num: {
    type: GRID_TYPE.CHECKBOX,
    title: "间隔数",
  },
  time_interval: {
    type: GRID_TYPE.CHECKBOX,
    title: "时间间隔",
  },
  frequency: {
    type: GRID_TYPE.CHECKBOX,
    title: "频率",
  },
  node_output: {
    type: GRID_TYPE.CHECKBOX,
    title: "节点输出",
  },
  unit_output: {
    type: GRID_TYPE.CHECKBOX,
    title: "单元输出",
  },
  contact_output: {
    type: GRID_TYPE.CHECKBOX,
    title: "接触输出",
  },
  energy_output: {
    type: GRID_TYPE.CHECKBOX,
    title: "能量输出",
  },
  Unsupported_Card: {
    type: GRID_TYPE.CHECKBOX,
    title: "不支持的卡片",
  },
  Row_input_Keywords: {
    type: GRID_TYPE.INPUT,
    title: "行输入关键字",
  },
  Table_input_Keywords: {
    type: GRID_TYPE.INPUT,
    title: "表输入关键字",
  },
};

//  输出卡片初始值
interface Output {
  value: boolean;
  param: string;
  output_name: boolean;
  output: boolean;
  variable: boolean;
  interval_num: boolean;
  time_interval: boolean;
  frequency: boolean;
  node_output: boolean;
  unit_output: boolean;
  contact_output: boolean;
  energy_output: boolean;
  Unsupported_Card: {
    value: boolean;
    Row_input_Keywords: string;
    Table_input_Keywords: string;
  };
}

interface OutputBlock {
  name: string;
  id: string;
  color?: string;
  output?: Output;
}
const initialOutput: OutputBlock = {
  name: "output_1",
  id: "1",
  output: {
    value: true,
    param: "FIELD",
    output_name: true,
    output: true,
    variable: true,
    interval_num: true,
    time_interval: true,
    frequency: true,
    node_output: true,
    unit_output: true,
    contact_output: true,
    energy_output: true,
    Unsupported_Card: {
      value: true,
      Row_input_Keywords: "1",
      Table_input_Keywords: "1 row(s)",
    },
  },
};
function parseOutputblock(p: { [x: string]: any }) {
  const outputblock: OutputBlock = {
    name: p["name"],
    id: p["id"],
    output: {
      value: true,
      param: "FIELD",
      output_name: true,
      output: true,
      variable: true,
      interval_num: true,
      time_interval: true,
      frequency: true,
      node_output: true,
      unit_output: true,
      contact_output: true,
      energy_output: true,
      Unsupported_Card: {
        value: true,
        Row_input_Keywords: "1",
        Table_input_Keywords: "1 row(s)",
      },
    },
  };
  return outputblock;
}

const OUTPUTBLOCK_TYPE_initial = {
  OutputBlock: initialOutput,
};
type OutputblockTypeInitial = typeof OUTPUTBLOCK_TYPE_initial;

// 4 卡片props
interface CardEditorProps {
  keyward: InputProp;
  name: InputProp;
  id: InputProp;
  type: SelectProp;
  status: CheckboxProp;
  read: CheckboxProp;
  write: CheckboxProp;
  iteration_step: CheckboxProp;
  frequency: CheckboxProp;
  cover: CheckboxProp;
}

const cardEditorProps: CardEditorProps = {
  keyward: {
    type: GRID_TYPE.INPUT,
    title: "关键字",
  },
  name: {
    type: GRID_TYPE.INPUT,
    title: "名字",
  },
  id: {
    type: GRID_TYPE.DISABLED,
    title: "标识",
  },
  type: {
    type: GRID_TYPE.SELECT,
    title: "卡类型",
    options: [
      {
        label: "Restart",
        value: "Restart",
      },
    ],
  },
  status: {
    type: GRID_TYPE.CHECKBOX,
    title: "状态",
  },
  read: {
    type: GRID_TYPE.CHECKBOX,
    title: "读",
  },
  write: {
    type: GRID_TYPE.CHECKBOX,
    title: "写",
  },
  iteration_step: {
    type: GRID_TYPE.CHECKBOX,
    title: "迭代步",
  },
  frequency: {
    type: GRID_TYPE.CHECKBOX,
    title: "频率",
  },
  cover: {
    type: GRID_TYPE.CHECKBOX,
    title: "覆盖",
  },
};

//  输出卡片初始值
interface Card {
  keyward: string;
  name: string;
  id: string;
  type: string;
  status: boolean;
  color?: string;
  read: {
    value: boolean;
    iteration_step: boolean;
  };
  write: {
    value: boolean;
    frequency: boolean;
    cover: boolean;
  };
}

const initialCard: Card = {
  keyward: "*RESTART",
  name: "Card_1",
  id: "1",
  type: "Restart",
  status: true,
  read: {
    value: true,
    iteration_step: true,
  },
  write: {
    value: true,
    frequency: true,
    cover: true,
  },
};
function parseCard(p: { [x: string]: any }) {
  const card: Card = {
    keyward: "RESTART",
    name: p["name"],
    id: p["id"],
    type: "Restart",
    status: true,
    read: {
      value: true,
      iteration_step: true,
    },
    write: {
      value: true,
      frequency: true,
      cover: true,
    },
  };
  return card;
}

const CARD_TYPE_initial = {
  Card: initialCard,
};
type CardTypeInitial = typeof CARD_TYPE_initial;
//温度场
interface Temperature {
  name: string;
  id: string;
  temperature_type: string;
  applyTo: string;
  amplitude: string;
  magnitude: string;
  temperatureSelectObjects: string;
}
const initialTemperature: Temperature = {
  name: "Temperature_1",
  id: "1",
  temperature_type: "TEMP",
  applyTo: "node",
  amplitude: "Ramp",
  magnitude: "0.0",
  temperatureSelectObjects: "",
};
function parseTemperature(p: { [x: string]: any }) {
  const temperature: Temperature = {
    name: p["name"],
    id: p["id"],
    temperature_type: "TEMP",
    applyTo: "node",
    amplitude: "Ramp",
    magnitude: p["magnitude"],
    temperatureSelectObjects: "",
  };
  return temperature;
}

const TEMPERATURE_TYPE_initial = {
  Temperature: initialTemperature,
};
type TemperatureTypeInitial = typeof TEMPERATURE_TYPE_initial;

interface TemperatureEditorProps {
  name: InputProp;
  id: InputProp;
  temperature_type: SelectProp;
  applyTo: SelectProp;
  amplitude: SelectProp;
  magnitude: InputProp;
  temperatureSelectObjects: InputProp;
}

const temperatureEditorProps: TemperatureEditorProps = {
  name: {
    type: GRID_TYPE.INPUT,
    title: "名字",
  },
  id: {
    type: GRID_TYPE.DISABLED,
    title: "标识",
  },
  temperature_type: {
    type: GRID_TYPE.SELECT,
    title: "temperatureType",
    options: [
      {
        label: "TEMP",
        value: "TEMP",
      },
      {
        label: "TEMPBC",
        value: "TEMPBC",
      },
      {
        label: "TEMPP1",
        value: "TEMPP1",
      },
    ],
  },
  applyTo: {
    type: GRID_TYPE.SELECT,
    title: "应用到",
    options: [
      {
        label: "node",
        value: "node",
      },
      {
        label: "nodeSet",
        value: "nodeSet",
      },
    ],
  },
  amplitude: {
    type: GRID_TYPE.SELECT,
    title: "幅值曲线",
    options: [
      {
        label: "Ramp",
        value: "Ramp",
      },
    ],
  },
  magnitude: {
    type: GRID_TYPE.INPUT,
    title: "大小",
  },
  temperatureSelectObjects: {
    type: GRID_TYPE.BUTTON,
    title: "选择对象",
  },
};

interface NodeCoordinates {
  name: string;
  id: string;
  color: string;
  description: string;
  NCSselectNodes: string;
  system: string;
  systemType: string;
  relativeSize: string;
}
const initialNodeCoordinates: NodeCoordinates = {
  name: "Node CS_1",
  id: "1",
  color: "#000000",
  description: " ",
  NCSselectNodes: " ",
  system: " ",
  systemType: "displacement",
  relativeSize: "10",
};
function parseNodeCoordinates(p: { [x: string]: any }) {
  const nodeCoordinates: NodeCoordinates = {
    name: p["name"],
    id: p["id"],
    color: p["color"],
    description: " ",
    NCSselectNodes: " ",
    system: " ",
    systemType: "displacement",
    relativeSize: p["relativeSize"],
  };
  return nodeCoordinates;
}
const NODECOORDINATES_TYPE_initial = {
  NodeCoordinates: initialNodeCoordinates,
};
type NodeCoordinatesTypeInitial = typeof NODECOORDINATES_TYPE_initial;
interface NodeCoordinatesEditorProps {
  name: InputProp;
  id: InputProp;
  color: InputProp;
  description: InputProp;
  NCSselectNodes: InputProp;
  system: InputProp;
  systemType: SelectProp;
  relativeSize: InputProp;
}

const nodeCoordinatesEditorProps: NodeCoordinatesEditorProps = {
  name: {
    type: GRID_TYPE.INPUT,
    title: "名字",
  },
  id: {
    type: GRID_TYPE.DISABLED,
    title: "标识",
  },
  color: {
    type: GRID_TYPE.COLOR,
    title: "颜色",
  },
  description: {
    type: GRID_TYPE.INPUT,
    title: "描述",
  },
  NCSselectNodes: {
    type: GRID_TYPE.BUTTON,
    title: "选择节点",
  },
  system: {
    type: GRID_TYPE.BUTTON,
    title: "system",
  },
  systemType: {
    type: GRID_TYPE.SELECT,
    title: "应用到",
    options: [
      {
        label: "displacement",
        value: "displacement",
      },
      {
        label: "reference",
        value: "reference",
      },
    ],
  },
  relativeSize: {
    type: GRID_TYPE.INPUT,
    title: "相对大小",
  },
};

//材料方向
interface MaterialOrientations {
  name: string;
  id: string;
  description: string;
  MOselectElems: string;
  method: string;
  system: string;
  relativeSize: string;
}
const initialMaterialOrientations: MaterialOrientations = {
  name: "elem CS_1",
  id: "1",
  description: " ",
  MOselectElems: " ",
  method: "system ID",
  system: " ",
  relativeSize: "10",
};
function parseMaterialOrientations(p: { [x: string]: any }) {
  const materialOrientations: MaterialOrientations = {
    name: p["name"],
    id: p["id"],
    description: " ",
    MOselectElems: " ",
    method: "system ID",
    system: " ",
    relativeSize: p["relativeSize"],
  };
  return materialOrientations;
}
const MATERIALORIENTATIONS_TYPE_initial = {
  MaterialOrientations: initialNodeCoordinates,
};
type MaterialOrientationsTypeInitial = typeof MATERIALORIENTATIONS_TYPE_initial;
interface MaterialOrientationsEditorProps {
  name: InputProp;
  id: InputProp;
  description: InputProp;
  MOselectElems: InputProp;
  method: SelectProp;
  system: InputProp;
  relativeSize: InputProp;
}

const materialOrientationsEditorProps: MaterialOrientationsEditorProps = {
  name: {
    type: GRID_TYPE.INPUT,
    title: "名字",
  },
  id: {
    type: GRID_TYPE.DISABLED,
    title: "标识",
  },
  description: {
    type: GRID_TYPE.INPUT,
    title: "描述",
  },
  MOselectElems: {
    type: GRID_TYPE.BUTTON,
    title: "选择单元",
  },
  method: {
    type: GRID_TYPE.SELECT,
    title: "方式",
    options: [
      {
        label: "system ID",
        value: "system ID",
      },
      {
        label: "system Axis",
        value: "system Axis",
      },
      {
        label: "by Angle",
        value: "by Angle",
      },
    ],
  },
  system: {
    type: GRID_TYPE.BUTTON,
    title: "system",
  },
  relativeSize: {
    type: GRID_TYPE.INPUT,
    title: "相对大小",
  },
};
//场
interface Field {
  name: string;
  id: number;
  field_type: string;
  source: string;
  fieldFile: string;
  coordinateSystem: number;
  selectSystem?: string;
  realize: Realize;
}
interface Realize {
  value: boolean;
  entityType: string;
  fieldType: number;
  interpolation: number;
  searchRadius: number;
  scale: boolean;
  scaleFactor: number;
  fieldNodes: string;
  fieldColumn: number;
  fieldShow: string;
  fieldClear: string;
}
const initialField: Field = {
  name: "Field_1",
  id: 1,
  field_type: "Discrete",
  source: "csv file",
  fieldFile: "选择文件",
  coordinateSystem: 0,
  realize: {
    value: true,
    entityType: "Nodes",
    fieldType: 0,
    interpolation: 0,
    searchRadius: 0.0,
    scale: true,
    scaleFactor: 1,
    fieldNodes: "0 node(s)",
    fieldColumn: 0,
    fieldShow: "Show",
    fieldClear: "Clear",
  },
};
function parseField(p: { [x: string]: any }) {
  const field: Field = {
    name: p["name"],
    id: p["id"],
    field_type: "Discrete",
    source: "csv file",
    fieldFile: "选择文件",
    coordinateSystem: 0,
    realize: {
      value: true,
      entityType: "Nodes",
      fieldType: p["fieldType"],
      interpolation: p["interpolation"],
      searchRadius: p["searchRadius"],
      scale: true,
      scaleFactor: p["scaleFactor"],
      fieldNodes: p["nodes"] + " node(s)",
      fieldColumn: p["columnIndex"],
      fieldShow: "Show",
      fieldClear: "Clear",
    },
  };
  return field;
}

const FIELD_TYPE_initial = {
  Field: initialField,
};
type FieldTypeInitial = typeof FIELD_TYPE_initial;

interface FieldEditorProps {
  name: InputProp;
  id: InputProp;
  field_type: InputProp;
  source: InputProp;
  fieldFile: InputProp;
  coordinateSystem: SelectProp;
  selectSystem?: SelectProp;
  realize: InputProp;
  entityType: InputProp;
  fieldType: SelectProp;
  interpolation: SelectProp;
  searchRadius: InputProp;
  scale: InputProp;
  scaleFactor: InputProp;
  fieldNodes: InputProp;
  fieldColumn: SelectProp;
  fieldApply: InputProp;
  fieldShow: InputProp;
  fieldClear: InputProp;
}

const fieldEditorProps: FieldEditorProps = {
  name: {
    type: GRID_TYPE.INPUT,
    title: "名字",
  },
  id: {
    type: GRID_TYPE.DISABLED,
    title: "标识",
  },
  field_type: {
    type: GRID_TYPE.DISABLED,
    title: "类型",
  },
  source: {
    type: GRID_TYPE.DISABLED,
    title: "源",
  },
  fieldFile: {
    type: GRID_TYPE.BUTTON,
    title: "文件",
  },
  coordinateSystem: {
    type: GRID_TYPE.SELECT,
    title: "坐标系",
    options: [
      {
        label: "Global System",
        value: 0,
      },
      {
        label: "Local System",
        value: 1,
      },
    ],
  },
  selectSystem: {
    type: GRID_TYPE.SELECT,
    title: "选择坐标系",
    options: [
      {
        label: "0 Coordinate System",
        value: "0 Coordinate System",
      },
    ],
  },
  realize: {
    type: GRID_TYPE.CHECKBOX,
    title: "实现",
  },
  entityType: {
    type: GRID_TYPE.DISABLED,
    title: "接触面类型",
  },
  fieldType: {
    type: GRID_TYPE.SELECT,
    title: "场类型",
    options: [
      {
        label: "Temperature",
        value: 0,
      },
      {
        label: "Displacement",
        value: 1,
      },
      {
        label: "Force",
        value: 2,
      },
      {
        label: "Moment",
        value: 3,
      },
    ],
  },
  interpolation: {
    type: GRID_TYPE.SELECT,
    title: "差值",
    options: [
      {
        label: "Linear",
        value: 0,
      },
      {
        label: "Proximity",
        value: 1,
      },
    ],
  },
  searchRadius: {
    type: GRID_TYPE.FLOAT,
    title: "搜索半径",
  },
  scale: {
    type: GRID_TYPE.CHECKBOX,
    title: "缩放",
  },
  scaleFactor: {
    type: GRID_TYPE.FLOAT,
    title: "缩放因子",
  },
  fieldNodes: {
    type: GRID_TYPE.BUTTON,
    title: "节点",
  },
  fieldColumn: {
    type: GRID_TYPE.SELECT,
    title: "column",
    options: [],
  },
  fieldApply: {
    type: GRID_TYPE.BUTTON,
    title: "Apply",
  },
  fieldShow: {
    type: GRID_TYPE.BUTTON,
    title: "Show",
  },
  fieldClear: {
    type: GRID_TYPE.BUTTON,
    title: "Clear",
  },
};
type SelectMaterial =
  | MAT1
  | MAT8
  | MAT9
  | PSHELL
  | PCOMP
  | PBUSH
  | OutputBlock
  | LoadConstraint
  | LoadCoordinates
  | Force
  | Displacement
  | Card
  | Temperature
  | NodeCoordinates
  | MaterialOrientations
  | NodesSet
  | ElementsSet
  | ComponentsSet
  | SetsSet
  | Field;
type EditorProps =
  | LoadConstraintEditorProps
  | LoadCoordinatesEditorProps
  | MaterialEditorProps
  | PropertyEditorProps
  | ForceEditorProps
  | DisplacementEditorProps
  | OutputEditorProps
  | CardEditorProps
  | SetEditorProps
  | TemperatureEditorProps
  | NodeCoordinatesEditorProps
  | MaterialOrientationsEditorProps
  | SetEditorProps
  | FieldEditorProps;
type PropsInitial =
  | MaterialTypeInitial
  | PropertyTypeInitial
  | LoadConstraintTYPEInitial
  | ForceTYPEInitial
  | LoadCoordinateTYPEInitial
  | DisplacementTYPEInitial
  | OutputblockTypeInitial
  | CardTypeInitial
  | TemperatureTypeInitial
  | NodeCoordinatesTypeInitial
  | MaterialOrientationsTypeInitial
  | SetsTypeInitial
  | FieldTypeInitial;

export {
  materialEditorProps,
  propertyEditorProps,
  loadConstraintEditorProps,
  loadCoordinatesEditorProps,
  temperatureEditorProps,
  nodeCoordinatesEditorProps,
  fieldEditorProps,
  initialLoadConstraint,
  initialCoordinates,
  initialForce,
  initialDisplacement,
  initialTemperature,
  initialNodeCoordinates,
  initialMaterialOrientations,
  forceEditorProps,
  displacementEditorProps,
  materialOrientationsEditorProps,
  Force_TYPE_initial,
  Load_Coordinates_TYPE_initial,
  Displacement_TYPE_initial,
  outputEditorProps,
  cardEditorProps,
  LoadCoordinates,
  GRID_TYPE,
  MATERIAL_TYPE,
  PROPERTY_TYPE,
  initialMaterialMAT1,
  initialMaterialMAT8,
  initialMaterialMAT9,
  initialPropertyPSHELL,
  Load_Constraint_TYPE_initial,
  initialPropertyPCOMP,
  initialPropertyPBUSH,
  initialOutput,
  initialCard,
  initialNodesSet,
  initialElementsSet,
  initialComponentsSet,
  initialSetsSet,
  initialField,
  setEditorProps,
  PROPERTY_TYPE_initial,
  MATERIAL_TYPE_initial,
  OUTPUTBLOCK_TYPE_initial,
  CARD_TYPE_initial,
  TEMPERATURE_TYPE_initial,
  NODECOORDINATES_TYPE_initial,
  MATERIALORIENTATIONS_TYPE_initial,
  FIELD_TYPE_initial,
  SETS_TYPE_initial,
  SelectMaterial,
  EditorProps,
  PropsInitial,
  MAT1,
  parseMaterial,
  parseProperty,
  parseSet,
  parseOutputblock,
  parseCard,
  parseTemperature,
  parseNodeCoordinates,
  parseMaterialOrientations,
  parseField,
};
